#!/usr/bin/env bash

# 下载Ubuntu镜像： http://mirrors.163.com/ubuntu-releases
# 阿里源： https://developer.aliyun.com/mirror/ubuntu

if [ `whoami` != "root" ];then
  echo "must be root"
  exit 1
fi

host=$1
if [ -z "$host" ]
then
  host='http://dev8.cn:8000/static/ops'
fi

apt-get install -y curl
echo "添加源 aliyun ..."
# 查看版本号： cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f 2   --> 18.04
# curl -o  /etc/apt/sources.list  $host/aliyun-ubuntu-$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f 2).source
sed -i "s|http://archive.ubuntu.com|https://mirrors.aliyun.com|g" /etc/apt/sources.list
sed -i "s|https://archive.ubuntu.com|https://mirrors.aliyun.com|g" /etc/apt/sources.list


echo "升级系统..."
apt-get clean all
apt-get update
apt-get upgrade -y

echo "安装依赖包..."
apt-get install -y software-properties-common openssh-server nginx wget git vim apt-utils daemon psmisc net-tools apt-transport-https ca-certificates

chmod a+rw -R /opt/

wget -q -O - $host/jdk.sh | bash
wget -q -O - $host/maven.sh | bash
wget -q -O - $host/node-js.sh | bash
wget -q -O - $host/python3.sh | bash
wget  $host/kill-grep.py -P /usr/bin -N

chmod a+x /usr/bin/kill-grep.py

# 安装docker指定版本
wget -q -O - $host/ubuntu-docker.sh | bash


echo "完成。"
#使用方法
# 首先安装 curl  , 设置 root 密码： sudo passwd root , 以 root 执行： sudo -s
# curl -fsSL http://dev8.cn:8000/static/ops/ubuntu-server.sh | bash